#ifndef _PWM_H_
#define _PWM_H_

//PWM module register map definiton
typedef struct
{
	volatile unsigned int PWM_MODE;
	volatile unsigned int PWM_CNT_CONFIG;
	volatile unsigned int PWM_OP_ENABLE;
	volatile unsigned int PWM_ERROR_CNT;
	volatile unsigned int PWM_ERROR_CNT_CLEAR;
	volatile unsigned int ASRC_MODE;
	volatile unsigned int ASRC_BYPASS;
	volatile unsigned int ASRC_OFFSET;
	volatile unsigned int ASRC_OUT_SAMPL_RATE;
	volatile unsigned int ASRC_IN_SAMPL_RATE;
	volatile unsigned int ASRC_RADIO_RATE_CFG;
	volatile unsigned int ASRC_LOCK;
	volatile unsigned int RSV[4];
	volatile unsigned int FIFO_PORT;
	volatile unsigned int FIFO_STATUS;
	volatile unsigned int FIFO_RESET;
}ASRC_PWM_REG;

//PWM register configuration
#define ASRC_RX_FIFO_BYPASS          (1 << 2)
#define ASRC_RX_FIFO_ENABLE          (0 << 2)
#define ASRC_RX_FIFO_BYPASS          (1 << 2)
#define ASRC_SINGLE_CHANNEL          (1 << 0)
#define ASRC_FUNC_BYPASS             (1 << 0)
#define ASRC_OFFSET_CFG              (0 << 0)
#define SAMPLE_RATE_16K              16
#define SAMPLE_RATE_32K              32
#define RATE_MULTI_PARAM             20
#define ASRC_RADIO_RATE              0x80000

#define PWM_FUNC_BYPASS              (1 << 8)
#define PWM_SW_RESET                 (1 << 7)
#define PWM_NORMAL_MODE              (1 << 6)
#define PWM_INTERPOLATION_MODE       (0 << 6)
#define PWM_CLK_SEL_135168KHZ        (1 << 4)
#define PWM_NORMAL_OUTPUT_32K        (0 << 4)
#define PWM_NORMAL_OUTPUT_48K        (1 << 4)
#define PWM_NORMAL_OUTPUT_96K        (2 << 4)
#define PWM_NORMAL_OUTPUT_128K       (3 << 4)
#define PWM_INTERPOLATION_OUTPUT_8K  (0 << 0)
#define PWM_INTERPOLATION_OUTPUT_16K (1 << 0)
#define PWM_INTERPOLATION_OUTPUT_32K (2 << 0)
#define PWM_WORK_CLK                 135168
#define PWM_REG_OP_ENABLE            (1 << 0)
#define PWM_ERR_CNT_CLEAR            (1 << 0)

#define ASRC_TxFIFO_CLEAR            (1 << 0)
#define ASRC_RxFIFO_CLEAR            (1 << 1)
#define PWM_FIFO_CLEAR               (1 << 2)
#define PWM_LFIFO_CLEAR              (1 << 3)
#define PWM_RFIFO_CLEAR              (1 << 4)

//PWM related SCU register configuration
#define SCU_PIN_MUX0_OFFSET          0x0
#define SCU_IP_RESET                 (SYSC_PA_BASE + 0x81C)
#define SCU_IP_RESET_PWM             (1 << 7)
#define SCU_PWM0_CFG                 (2 << 0)
#define SCU_PWM1_CFG                 (2 << 12)

void pwm_module_init(void);

#endif
